-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Skip song if track is empty. #1164
Conversation
#1163 is for the same thing. Not sure which is better. Maybe have a look at that too. |
spotdl/search/utils.py
Outdated
if song.get_youtube_link() != None: | ||
playlistTracks.append(song) | ||
|
||
# check if more tracks are to be passed | ||
if playlistResponse['next']: | ||
playlistResponse = spotifyClient.playlist_tracks( | ||
playlistUrl, | ||
offset = len(playlistTracks) | ||
offset = playlistResponse['offset'] + playlistResponse['limit'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not need necessary, is it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a track is None
, playlisttracks will not increase. So you will request duplicate entries
And if you have, in theory, 100 None
entries. The offset will stay the same and the program will be stuck
So I would say it's essential
@@ -79,17 +79,20 @@ def get_playlist_tracks(playlistUrl: str) -> List[SongObj]: | |||
while True: | |||
|
|||
for songEntry in playlistResponse['items']: | |||
if songEntry['track'] is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we'd need to check both of them. Because in #1147 the songEntry['track']
is None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to have a none None
track, but with an empty id?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess so. If the track would be empty we would get object is not subscriptable
error, but in the screenshot above songEntry['track']['id']
returns None
for some reason
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bee395 can you pull from |
4525272
to
ad77fa2
Compare
ad77fa2
to
c377d06
Compare
* Run regressions on CI (#1158) Authored by @aklajnert * Use argparse instead of raw `sys.argv` (#1157) Authored by @aklajnert * FIxed error caused by songs with ':' in name (#1162) Authored by @MikhailZex * Fixed TypeError when downloading tracks (#1177) Authored by @xnetcat * Bump version to 3.3.2 * Lint with flake8, fix code to pass it (#1178) Authored by @aklajnert * Fixed flake8 (#1181) Authored by @aklajnert * Skip song if track is empty. (#1164) Authored by @bee395 Co-authored-by: Andrzej Klajnert <github@aklajnert.pl> Co-authored-by: Michael George <MikhailZex@gmail.com> Co-authored-by: Jakub <42355410+xnetcat@users.noreply.github.com> Co-authored-by: bee395 <bee395@users.noreply.github.com>
Description
Some playlist requested with spotipy contain empty tracks.
This change will skip those tracks, and use the correct offset for the next request.
Types of changes